package dierweek;

import java.util.Scanner;

public class moweishuxiangjia {
    public static void main(String[] args) {
        System.out.println("请输入任意一个N位数");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        //判断位数
      int leg=0;
      int numCopy=num;
      while (num!=0){
          leg++;
          num=num/10;
      }
      int r=1;
      for (int i =1;i<=leg-1;i++){
          r=r*10;
      }
      int numCopy1=numCopy%r;
        System.out.println(+numCopy1);//1234输出234
        int sum=0;
        while (numCopy1!=0){
            sum+=numCopy1%10;

            numCopy1/=10;//numCopy=numCopy/10;
        }
        System.out.println("sum="+sum);
    }
}
